/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#include <lib3d/hard/Hardware.h>

namespace liba
{
namespace lib3d
{
namespace hard
{
namespace macx
{

class Hardware : public hard::Hardware
{
	bool start_render( const RenderList & render_list, RenderTarget * render_target );
public:
	Hardware();
	virtual ~Hardware();
	// for user hardware reporting
	virtual std::string get_hardware_name()
	{
		return "OpenGL";
	}
	// for mode negotiation and setting
	virtual std::string get_name()
	{
		return "OpenGL";
	}

	virtual bool set_mode_internal(WindowImpl * window, const Strings & attribute_values);
	virtual void stop_mode();

	// can alter render_list in some ways - sort models, reorder lights, etc.
	virtual void render( RenderList * render_list, RenderTarget * render_target );

	/** This method is not allowed to return 0 */
	virtual Texture * create_texture(int mipmap_levels, const pictureformat::Format & desired_format, int width, int height);
	/** This method is not allowed to return 0 */
	virtual TextureCubic * create_texture_cubic(int mipmap_levels, const pictureformat::Format & desired_format, int width, int height) { return 0; }

	/** This method is not allowed to return 0 */
	virtual VertexBuffer * create_vertex_buffer( bool dynamic = false );
	/** This method is not allowed to return 0 */
	virtual IndexBuffer * create_index_buffer() { return 0; }
	/** This method is not allowed to return 0 */
	virtual PointBuffer * create_point_buffer() { return 0; }
	/** This method can return 0 if render targets are unsupported */
	virtual RenderTarget * create_render_target(const Atom & render_target_name, int width, int height) { return 0; }
	virtual TextureBase * get_render_target(const Atom & render_target_name) { return 0; }

	virtual bool is_operational() const { return true; }

	virtual const int get_width()const
	{ return 0; }
	virtual const int get_height()const
	{ return 0; }

	virtual bool start_frame();
	virtual void flip();
	
	virtual bool start_scene(double left, double right, double top, double bottom) { return true; }
private:
	Matrix curr_mat[1024];
	int curr_pos;
	int old_pos;
};

}//namepsace macx
}//namespace hard
}//namespace lib3d
}//namespace liba

using namespace liba;